//package Els;
import java.io.IOException;
//import javax.swing.JOptionPane;
import javax.xml.parsers.*;
import org.w3c.dom.*;
import org.xml.sax.SAXException;
import java.awt.*;
@SuppressWarnings("serial")
public class Top extends Panel{
	private Panel ch[]=new Panel[10];
	Top(){
		this.setLayout(new GridLayout(11,1));
		this.setBackground(Color.black);
		this.setForeground(Color.white);
		this.add(new Label("Top 10"));
		try{
			DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
			DocumentBuilder builder=factory.newDocumentBuilder();
			Document doc=builder.parse("data.xml");
			doc.normalize(); 
			NodeList people =doc.getElementsByTagName("people");
				for(int i=0;i<people.getLength();i++){
					Element peo=(Element)people.item(i);
					String scors=peo.getElementsByTagName("score").item(0).getFirstChild().getNodeValue();
					String names=peo.getElementsByTagName("name").item(0).getFirstChild().getNodeValue();
					ch[i]=new Panel();				
					ch[i].add(new Label("No "+String.valueOf(i+1)+":"));
					ch[i].add(new Label(names));
					ch[i].add(new Label(scors));
					//ch[i].add(new Label("gyj"));
					this.add(ch[i]);
				}
			}
			catch(ParserConfigurationException ew){	
			}
			catch(IOException es){	
			}
			catch(SAXException et){	
			}
		}
}
